<template>
  <div class="column">
    <router-view/>
    <div class="panelLabel">
      <h1>{{year}}年度任务：</h1>
      <h1>总量&nbsp;</h1>
      <h3>{{total}} 亿元&nbsp; &nbsp;</h3>
      <h1>增速&nbsp;</h1>
      <h3 v-bind:style="{ color: color1 }">{{growthRate}}%&nbsp; </h3>
      <h1>完成度&nbsp;</h1>
      <h3>{{schedule}}%</h3>
      <h1>&nbsp;规上工业企业总数&nbsp;</h1>
      <h3>&nbsp;{{qys}}个</h3>
      <div class="panelLabel-foot"></div>
    </div>
    <div class="panelSmLong">
      <div class="boxb"><h2>{{year}}年月度规上工业总产值</h2></div>
      <div class="panelSmLong1">
        <v-chart class="chart" :option="option1" :autoresize="true"></v-chart>
      </div>
      <div class="panelSmLong-foot"></div>
    </div>
    <div class="panelSmLong">
      <div class="boxb"><h2>{{year}}年月度累计规上工业总产值</h2></div>
      <div class="panelSmLong1">
        <v-chart class="chart" :option="option3" :autoresize="true"></v-chart>
      </div>
      <div class="panelSmLong-foot"></div>
    </div>
  </div>
</template>

<script>
import * as echarts from "echarts";

export default {
  name: "jj6",
  mounted() {
    this.$parent.reverseColor6();
  },
  computed: {
    year() {
      return this.$store.year
    },
    month() {
      return this.$store.month
    }
  },
  watch: {
    '$store.time': {
      immediate: true,
      deep: true,
      handler(v) {
        this.initData();
        this.gettop();
        this.getdata1();
        this.getdata2();
        this.getdata3();
        this.getqy();
      }
    }
  },
  methods: {
    gettop(){
      this.$util.http.get('/economicIndicators/getAnnualTasks?year='+this.year+'&&indicators=规上工业总产值').then(res=>{
        if(res.data==null){
          this.total = "-";
          this.growthRate = "-";
          this.schedule = "-";
          return
        }
        this.total = res.data.total;
        this.growthRate = res.data.growthRate;
        this.schedule = (res.data.schedule*100).toFixed(2);
        if(Number(res.data.growthRate)>0){
          this.color1 = 'green'
        }else{
          this.color1 = 'red'
        }
      })
    },
    getdata1(){
      // axios.get('http://localhost:28080/prod-api/economicIndicators/getEconomicIndicatorsByIndicators',{
      //   params:{
      //     year:this.year,
      //     indicators:'规上工业总产值',
      //   }
      // }).then(res=>{
      this.$util.http.get('/economicIndicators/getEconomicIndicatorsByIndicators?year='+this.year+'&&indicators=规上工业总产值').then(res=>{
        if (res.data[0]==null) {
          this.option1.series[0].data = []
          this.option1.series[1].data = []
          this.option1.series[2].data = []
          return
        }
        for (var i =0 ;i < res.data.length;i++) {
          this.data1[res.data[i].month-1] = res.data[i].thisMonth
        }
        this.option1.series[0].data = this.data1
        this.option1.series[1].data = this.data1
        this.option1.series[2].data = this.data1
      })
    },
    getdata2(){
      // axios.get('http://localhost:28080/prod-api/economicIndicators/getEconomicIndicatorsByIndicators',{
      //   params:{
      //     year:this.year,
      //     indicators:'规上工业总产值',
      //   }
      // }).then(res=>{
      this.$util.http.get('/economicIndicators/getEconomicIndicatorsByIndicators?year='+this.year+'&&indicators=规上工业总产值').then(res=>{
        if (res.data[0]==null) {
          this.option1.series[3].data = []
          return
        }
        for (var i =0 ;i < res.data.length;i++) {
          this.data2[res.data[i].month-1] = res.data[i].monthOnMonth
        }
        this.option3.series[3].data = this.data2
      })
    },
    getdata3(){
      // axios.get('http://localhost:28080/prod-api/economicIndicators/getEconomicIndicatorsByIndicators',{
      //   params:{
      //     year:this.year,
      //     indicators:'规上工业总产值',
      //   }
      // }).then(res=>{
      this.$util.http.get('/economicIndicators/getEconomicIndicatorsByIndicators?year='+this.year+'&&indicators=规上工业总产值').then(res=>{
        if (res.data[0]==null) {
          this.option3.series[0].data = []
          return
        }
        for (var i =0 ;i < res.data.length;i++) {
          this.data3[res.data[i].month-1] = res.data[i].accumulate
        }
        this.option3.series[0].data = this.data3
        this.option3.series[1].data = this.data3
        this.option3.series[2].data = this.data3
      })
    },
    getqy(){
      this.$util.http.get('/economicIndicators/getAllqy?year='+this.year+'&&month='+this.month).then(res=>{
        this.qys = res.data;
      })
    },
    initData() {
      this.data1 = ['-','-','-','-','-','-','-','-','-','-','-','-']
      this.data2 = ['-','-','-','-','-','-','-','-','-','-','-','-']
      this.data3 = ['-','-','-','-','-','-','-','-','-','-','-','-']
    }
  },

  data() {
    return {
      color1:'',
      total:'',
      growthRate:'',
      schedule:0,
      data1:['-','-','-','-','-','-','-','-','-','-','-','-'],//当月值
      data2:['-','-','-','-','-','-','-','-','-','-','-','-'],//当月同比值
      data3:['-','-','-','-','-','-','-','-','-','-','-','-'],//当月累计值

      qys:0,

      option1: {
        tooltip: {
          backgroundColor: "#00194A",
          trigger: 'axis',
          textStyle: {
            fontSize: 16,
            color: "#fff",
          },
          formatter: ((params) => {
            return `<div style="font-size:15px;">${params[0].axisValue}</div>
              <div style="font-size:16px;margin-top:5px;">
                <p style="display: inline;color: #87CEEB;font-size: 15px;">当月：</p>
                <p style="display: inline;color: rgba(18, 224, 254, 1);font-size: 18px;">${this.data1[params[0].dataIndex]}</p>
                <p style="display: inline;color: rgba(18, 224, 254, 1);font-size: 14px; ">亿元</p>
              </div>`;
          })
        },
        grid: {
          top: '20%',
          left: '5%',
          right: '2%',
          bottom: '3%',
          show: true,
          borderColor: "#012f4a",
          containLabel: true
        },
        color: ['#4472C5', '#ED7C30'],
        legend: {
          orient: 'horizontal',
          right: '12.5%',
          textStyle: {
            color: '#A1D5FF',
            fontSize: 16
          },
        },
        xAxis: [{
          data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
          show: true,
          axisLabel: {
            interval: 0,
            textStyle: {
              color: '#97C9FF',
              fontSize: '16'
            },
            margin: 15 // 刻度标签与轴线之间的距离。
          },
          axisLine: {
            show: true,
            lineStyle: {
              type: 'solid',
              color: 'gray',
              opacity: 1
            }
          },
          axisTick: {
            show: false
          },
          boundaryGap: true,
          splitLine: {
            show: false,
            width: 0.08,
            lineStyle: {
              type: "solid",
              color: "#red"
            }
          }
        }],
        yAxis: [
          {
            name: '(亿元)',
            nameTextStyle: {
              align: 'left',
              color: '#97C9FF',
              padding: [0, 0, 0, -50],
              fontSize: 10,
            },
            //背景网格为虚线
            splitLine: {
              show: true,
              lineStyle: {
                type: 'dashed',
                opacity: 0.5
              }
            },
            axisTick: {
              show: false
            },
            axisLine: {
              show: false
            },
            axisLabel: {
              textStyle: {
                color: '#97C9FF',
                fontSize: '16',
              }
            }
          },
          {
            name: '',
            nameTextStyle: {
              color: '#97C9FF',
              fontSize: 10,
            },
            splitLine: {show: false},
            axisLine: {show: false},
            axisTick: {show: false},
            axisLabel: {
              textStyle: {
                color: '#97C9FF',
                fontSize: '16',
              }
            }
          }],
        series: [
          //data传月度值
          {
            data: this.data1,
            stack: "zs",
            type: "bar",
            barMaxWidth: "auto",
            barWidth: 25,
            itemStyle: {
              color: {
                x: 0,
                y: 0,
                x2: 0,
                y2: 1,
                type: "linear",
                global: false,
                colorStops: [
                  {
                    offset: 0,
                    color: "#5EA1FF",
                  },
                  {
                    offset: 1,
                    color: "#90BEFF",
                  },
                ],
              },
            },
          },
          //data传月度值
          {
            name: '月度值',
            data: this.data1,
            type: "pictorialBar",
            barMaxWidth: "1",
            symbol: "diamond",
            symbolOffset: [0, "50%"],
            symbolSize: [30, 6],
            zlevel: 2,
            itemStyle: {
              normal: {
                label:{
                  show: true, //开启显示
                  position: 'top', //在上方显示
                  textStyle: { //数值样式
                    color: '#5EA1FF',
                    fontSize: 16
                  }
                },
                // color: '#87CEEB',
              },
            },
          },
          //data传月度值
          {
            data: this.data1,
            type: "pictorialBar",
            barMaxWidth: "5",
            symbolPosition: "end",
            symbol: "diamond",
            symbolOffset: [0, "-50%"],
            symbolSize: [30, 6],
            zlevel: 2,
            itemStyle: {
              normal: {
                color: '#87CEEB',
              },
            },
          }
        ]
      },

      option3: {
        tooltip: {
          backgroundColor: "#00194A",
          trigger: 'axis',
          textStyle: {
            fontSize: 16,
            color: "#fff",
          },
          formatter: ((params) => {
            return `<div style="font-size:15px;">${params[0].axisValue}止累计</div>
              <div style="font-size:16px;margin-top:5px;">
                <p style="display: inline;color: #87CEEB;font-size: 15px;">累计：</p>
                <p style="display: inline;color: rgba(18, 224, 254, 1);font-size: 18px;">${this.data3[params[0].dataIndex]}</p>
                <p style="display: inline;color: rgba(18, 224, 254, 1);font-size: 14px; ">亿元</p>
              </div>
              <div style="font-size:16px;margin-top:5px;">
                <p style="display: inline;color: #87CEEB;font-size: 15px;">同比：</p>
                <p style="display: inline;color: lawngreen;font-size: 18px;">${this.data2[params[0].dataIndex]}</p>
                <p style="display: inline;color: lawngreen;font-size: 14px; ">%</p>
              </div>`;
          })
        },
        grid: {
          top: '20%',
          left: '5%',
          right: '0%',
          bottom: '3%',
          show: true,
          borderColor: "#012f4a",
          containLabel: true
        },
        color: ['#4472C5', '#ED7C30'],
        legend: {
          orient: 'horizontal',
          right: '12.5%',
          textStyle: {
            color: '#A1D5FF',
            fontSize: 16
          },
        },
        xAxis: [{
          data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
          show: true,
          axisLabel: {
            interval: 0,
            textStyle: {
              color: '#97C9FF',
              fontSize: '16'
            },
            margin: 15 // 刻度标签与轴线之间的距离。
          },
          axisLine: {
            show: true,
            lineStyle: {
              type: 'solid',
              color: 'gray',
              opacity: 1
            }
          },
          axisTick: {
            show: false
          },
          boundaryGap: true,
          splitLine: {
            show: false,
            width: 0.08,
            lineStyle: {
              type: "solid",
              color: "#red"
            }
          }
        }],
        yAxis: [
          {
            name: '(亿元)',
            nameTextStyle: {
              align: 'left',
              color: '#97C9FF',
              padding: [0, 0, 0, -50],
              fontSize: 10,
            },
            //背景网格为虚线
            splitLine: {
              show: true,
              lineStyle: {
                type: 'dashed',
                opacity: 0.5
              }
            },
            axisTick: {
              show: false
            },
            axisLine: {
              show: false
            },
            axisLabel: {
              textStyle: {
                color: '#97C9FF',
                fontSize: '16',
              }
            }
          },
          {
            name: '(%)',
            nameTextStyle: {
              color: '#97C9FF',
              fontSize: 10,
            },
            splitLine: {show: false},
            axisLine: {show: false},
            axisTick: {show: false},
            axisLabel: {
              textStyle: {
                color: '#97C9FF',
                fontSize: '16',
              }
            }
          }],
        series: [
          //data传月度值
          {
            data: this.data1,
            stack: "zs",
            type: "bar",
            barMaxWidth: "auto",
            barWidth: 25,
            itemStyle: {
              color: {
                x: 0,
                y: 0,
                x2: 0,
                y2: 1,
                type: "linear",
                global: false,
                colorStops: [
                  {
                    offset: 0,
                    color: "#5EA1FF",
                  },
                  {
                    offset: 1,
                    color: "#90BEFF",
                  },
                ],
              },
            },
          },
          //data传月度值
          {
            name: '月度累计值',
            data: this.data1,
            type: "pictorialBar",
            barMaxWidth: "1",
            symbol: "diamond",
            symbolOffset: [0, "50%"],
            symbolSize: [30, 6],
            zlevel: 2,
            itemStyle: {
              normal: {
                label:{
                  show: true, //开启显示
                  position: 'top', //在上方显示
                  textStyle: { //数值样式
                    color: '#5EA1FF',
                    fontSize: 16
                  }
                },
                // color: '#87CEEB',
              },
            },
          },
          //data传月度值
          {
            data: this.data1,
            type: "pictorialBar",
            barMaxWidth: "5",
            symbolPosition: "end",
            symbol: "diamond",
            symbolOffset: [0, "-50%"],
            symbolSize: [30, 6],
            zlevel: 2,
            itemStyle: {
              normal: {
                color: '#87CEEB',
              },
            },
          },
          //data传月度累计同比，黄色的折线图
          {
            name: '月度累计同比',
            'z': 9,
            yAxisIndex: 1,
            type: 'line',
            data: this.data2,
            symbolSize: '8',//折线图原点大小
            lineStyle: {
              normal: {
                width: 3,
                color: '#ffbb00' // 线条颜色
              },
              borderColor: 'rgba(0,0,0,.4)'
            },
          }
        ]
      },
    }
  }
}
</script>

<style scoped>

</style>